<template>
	<div>
		<el-form ref="form" :model="form" label-width="80px" v-if="form">
			<el-form-item label="编号" v-if="$store.state.userInfo.type == '2'"><el-input v-model="form.id"></el-input></el-form-item>
			<el-form-item label="姓名"><el-input v-model="form.name"></el-input></el-form-item>
			<el-form-item label="性别">
				<el-select v-model="form.sex" placeholder="请选择性别">
					<el-option label="男" value="男"></el-option>
					<el-option label="女" value="女"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="电话号码"><el-input v-model="form.telephone"></el-input></el-form-item>
			
			<el-form-item label="生日"><el-date-picker v-model="form.birthday" type="date" placeholder="选择日期"></el-date-picker></el-form-item>
			<el-form-item label="职位" v-if="$store.state.userInfo.type == '2'">
				<el-select v-model="form.duty" placeholder="请选择"><el-option v-for="item in $store.state.duties" :key="item" :label="item" :value="item"></el-option></el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="onSubmit">确定修改</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
export default {
	data(){
		return {
			form:null
		}
	},
	mounted:function(){
		this.form = this.$store.state.userInfo
	},
	methods:{
		onSubmit(){
			let that = this
			that.axios.post(that.$store.state.serverHost+'/'+(that.$store.state.userInfo.type==2?'administrator/changeAdmin/':'student/changeStudent/'),that.form)
				.then((res)=>{
					console.log(res)
					if(res.data=="修改成功") that.$message.success("修改成功")
					else that.$message.error("修改失败")
				})
				.catch((e)=>{
					that.$message.error("修改失败")
				})
		}
	}
};
</script>

<style scoped></style>
